package com.lanzhou.yuanfen.util;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */
public class DateUtil {


    /**
     * 获取最近一个礼拜(近七天)的参数
     * 0: 今天 1: 七天前
     *
     * @return
     */
    public static String[] getWeekParam() {
        String[] result = new String[2];
        LocalDate now = LocalDate.now();
        result[0] = now.plusDays(-1).toString() + " 23:59:59";
        LocalDate plusDays = now.plusDays(-7);
        result[1] = plusDays.toString() + " 00:00:00";
        return result;
    }


    /**
     * 获取最近一个礼拜(近七天)的时间(不包括今天的)
     *
     * @return
     */
    public static List<String> getWeekStr() {
        List<String> result = new ArrayList<>();
        LocalDate now = LocalDate.now();
        for (int i = -1; i > -8; i--) {
            LocalDate plusDays = now.plusDays(i);
            result.add(plusDays.toString());
        }
        return result;
    }


    /*anonymous static void main(String[] args) {
        String[] weekParam = getWeekParam();
        System.out.println(weekParam);
        List<String> weekStr = getWeekStr();
        System.out.println(weekStr);
    }*/


}
